package vn.mhg.web;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import vn.mhg.user.User;
import vn.mhg.user.UserManager;

import com.opensymphony.xwork2.ActionSupport;

public class WebAction extends ActionSupport implements SessionAware{

	private User user;
	
	public User getCurrentUser() {
		return user;
	}
	
	@Override
	public void setSession(Map<String, Object> session) {
		String sessionId = (String) session.get("FIBC_ID");
		user = UserManager.getInstance().getUser(sessionId);
		if (user == null) {
			user = UserManager.getInstance().createUser();
			session.put("FIBC_ID", user.sessionId);
		}		
	}

}
